


<extend name="Public:layout"/>
<block name="content">
<style type="text/css">

    .er{color:red;}
</style>
<div class="row-fluid sortable ui-sortable">
                <div class="box span12">
                    <div data-original-title="" class="box-header">
                        <h2><i class="halflings-icon white edit"></i><span class="break"></span>商品品牌添加</h2>
                        <div class="box-icon">
                            <a class="btn-setting" href="#"><i class="halflings-icon white wrench"></i></a>
                            <a class="btn-minimize" href="#"><i class="halflings-icon white chevron-up"></i></a>

                        </div>
                    </div>
                    <div class="box-content">
                        <form id="signupForm" enctype="multipart/form-data" class="form-horizontal" action="" method="post" >
                            <fieldset>

                              <div class="control-group">
                                    <label for="appendedInput" class="control-label">名称：</label>
                                    <div class="controls">
                                      <div class="input-append">
                                        <input type="text" size="16"  name="name">
                                      </div>

                                    </div>
                              </div>

                              <div class="control-group">
                                <label for="selectError" class="control-label">类型：</label>
                                <div class="controls">
                                  <select data-rel="chosen" id="selectError" style="" class="chzn-done" name="goods_type_id">
                                    <option value="0">请选择</option>
                                    <foreach name="type" item="v" key="k">
                                     <option value="{$v.id}" >{$v.name}</option>
                                    </foreach>
                                  </select>
                                </div>
                              </div>

                              <div class="control-group">
                                    <label for="appendedInput" class="control-label">排序：</label>
                                    <div class="controls">
                                      <div class="input-append">
                                        <input type="text" size="16"  name="sort">
                                      </div>

                                    </div>
                              </div>
                               <div class="control-group">
                                <label class="control-label">图标上传</label>
                                <div class="controls">

                                  <div class="uploader">
                                      <input type="file" id='file' name='piture'>
                                      <span class="filename" style="-moz-user-select: none;"></span>
                                      <span class="action" style="-moz-user-select: none;">选择图片</span>

                                  </div>
                                  <img id="img" width=60 height=60 src="" style="float:right;margin-right:1100px;" alt="">
                                </div>
                              </div>
                              <div class="control-group">
                                    <label for="appendedInput" class="control-label">url：</label>
                                    <div class="controls">
                                      <div class="input-append">
                                        <input type="text" size="16"  name="url">
                                      </div>

                                    </div>
                              </div>


                              <div class="form-actions">
                                <button class="btn btn-primary submit" type="submit">提交</button>

                              </div>
                            </fieldset>
                        </form>
                    </div>
                </div><!--/span-->

            </div>




</block>







<block name="js">

<script src="__PUBLIC__js/jquery.validate.min.js"></script>

    <script type="text/javascript">


    // 选择文件时动态显示图片在旁边
     function getObjectURL(file) {
        var url = null ;
        if (window.createObjectURL!=undefined) { // basic
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }

    $('#file').change(function() {

        $('#img').attr('src', getObjectURL($(this)[0].files[0])); // 或 this.files[0] this->input

    });



        $(function(){
            //调用表单验证插件进行表单验证
            $('#signupForm').validate({

                debug:false,
                rules:{
                    username:{
                        required:true,
                        rangelength:[2,10]
                    },
                    section:"required",
                    number:{
                        required:true,
                        digits:true
                    },
                     tel:{
                        required:true,
                        digits:true,
                        rangelength:[11,11]
                   },
                    address:"required",
                    password:{
                        required:true,
                        minlength:8
                    },
                    confirm_password:{
                        required:true,
                        minlength:8,
                        equalTo: "#password"
                    },
                    code:{
                        required:true,
                        rangelength:[6,6],
                        digits:true
                    },

                },

                messages:{
                     username:{
                        required:"请输入用户名",
                        rangelength:"用户名的长度在2-10之间"
                    },
                    section:"请输入所属部门",
                    number:{
                        required:"请输入工号",
                        digits:"工号为整数"
                    },
                    address:"请输入住址",
                    tel:{
                        required:"请输入手机号码",
                        digits:"必须为整数",
                        rangelength:"手机号码长度为11位"

                   },
                    password:{
                        required:"请输入密码",
                        minlength:"密码的长度最少为8位"
                    },
                     confirm_password:{
                        required:"请确认密码",
                        minlength:"密码长度不少于8位",
                        equalTo: "两次密码不一致"

                    },
                     code:{
                        required:"请输入校验码",
                        rangelength:"校验码长度为6位整数",
                         digits:"校验码长度为6位整数"
                    },
                },
                errorClass:'er',
            })

        })


    </script>
</block>